import type { CardListType, CardListParamsType, CardProportionType, AddCardParams, CardDetailType, RechargeParamsType, WatchCardType } from "@/types/card"
import { myGet, myPost, myRequest } from "@/utils/reuqest"

// 获取月卡列表请求
export const getCardListAPI = (params: CardListParamsType) => {
    return myGet<CardListType>('/parking/card/list', params)
}

// 获取月卡占有率请求
export const getCardProportionAPI = () => {
    return myGet<CardProportionType>('/parking/card/proportion')
}

// 添加月卡
export const addCardAPI = (obj: Partial<AddCardParams>) => {
    return myPost('/parking/card', obj)
}

// 删除月卡
export const deleteCardsAPI = (ids: number[]) => {
    return myRequest({
        url: `/parking/card/${ids.join(',')}`,
        method: 'DELETE'
    })
}

// 获取月卡（编辑续费）详情
export const getCardDetailAPI = (id: number) => {
    return myGet<CardDetailType>(`/parking/card/detail/${id}`)
}

// 编辑月卡
export const editCardAPI = (obj: CardDetailType) => {
    return myRequest({
        url: '/parking/card/edit',
        method: 'PUT',
        data: obj
    })
}

// 月卡续费
export const renewCardAPI = (obj: RechargeParamsType) => {
    return myPost('/parking/card/recharge', obj)
}

// 查看月卡详情
export const watchCardAPI = (id: number) => {
    return myGet<WatchCardType>(`/parking/card/${id}`)
}